package com.monitor.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.monitor.dao.ErpModelMapper;
import com.monitor.entity.ErpModel;
import com.monitor.service.ErpModelService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 品牌型号表 服务实现类
 * </p>
 *
 * @author LX
 * @since 2018-09-13
 */
@Service
public class ErpModelServiceImpl extends ServiceImpl<ErpModelMapper, ErpModel> implements ErpModelService {

    @Resource
    private ErpModelMapper modelMapper;

    @Override
    public ErpModel getChildModel(ErpModel model) {

        if(null==model){
            return null;
        }

        List<ErpModel> models=modelMapper.selectList(new EntityWrapper<ErpModel>().eq("pid",model.getZid()));
        if(0==models.size()){
            return model;
        }

        for (ErpModel m:models) {
            getChildModel(m);
        }
        model.setModel(models);
        return model;
    }

    @Override
    public List<ErpModel> getModelCustomerBycustIdList() {

        return modelMapper.getModelCustomerBycustIdList();
    }
}
